package com.dingding.transfer.stamper.constant;

import cn.hutool.core.date.DateUtil;
import com.dingding.transfer.stamper.entity.UseStampRecord;
import com.dingding.transfer.stamper.service.BusinessService;
import com.dingding.transfer.stamper.util.SpringContextUtil;

/**
 * @author wangxiyuan
 * @description
 * @createDate 2021/4/8 9:54
 **/
public interface TempletePara {
    String USE_TIME = "使用日期";

    String USE_STAMPER = "用章人";

    String STAMPER_SOURCE = "加盖印章";

    String CURRENT_TIMES = "当前次数";

    String LOCATION = "地址";

    String STAMPE_IMAGE = "盖章图片";

    String DD_FORM = "stamper";


    /**
     * 获取对应模板字段 应该填写的内容
     * @param filedName
     * @param record
     * @return
     */
    static String getContent(String filedName,UseStampRecord record){
        switch (filedName){
            case USE_TIME:
                return DateUtil.format(record.getUseTime(),"yyyy-MM-dd HH:mm:ss");
            case USE_STAMPER:
                return record.getUserName();
            case STAMPER_SOURCE:
                BusinessService businessService = SpringContextUtil.getBean(BusinessService.class);
                return businessService.getDeviceId(record.getUuid());
            case CURRENT_TIMES:
                return record.getUseCount().toString();
            case LOCATION:
                return record.getLocation();
            case STAMPE_IMAGE:
                return record.getFileUrl();
            default:
                return "";
        }
    }
}
